/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Entity;

import View.Pnl_Ground;
import zaire.PhoneMap;

/**
 *
 * @author federicosanchi
 */
public class Phone {
    
    private int x;
    private int y;
    private double myNumber;
    private AddressBook ab;
    
    int panelWidth;
    int panelHeight;
    
    public Phone(){
        //take boundaries
        panelWidth = Pnl_Ground.getInstance().getWidth();
        panelHeight = Pnl_Ground.getInstance().getHeight();
        //init the Phone location
        x = (int) (Math.random()*panelWidth);
        y = (int) (Math.random()*panelHeight);
        
        //creazione del numero di telefono
        myNumber = Math.random();
        
        //creazione rubrica
        ab = new AddressBook();
    }
    
    public void muoviRandom(){
        double n = Math.random();
        //muovi in alto
        if(n > 0 && n <= 0.250) y += 1;
        //muovi a dx
        if(n > 0 && n <= 0.250) x += 1;
        //muovi in basso
        if(n > 0 && n <= 0.250) y -= 1;
        //muovi a sx
        if(n > 0 && n <= 0.250) x -= 1;
    }
    
    public int getX(){
        return x;
    }
    
    public int getY(){
        return y;
    }
    
    public double getPhoneNumber(){
        return myNumber;
    }
    
    public void insertPhoneContact(double phoneNumber){
        if(phoneNumber != myNumber){
            ab.insertPhoneNumber(phoneNumber);
        }
    }
}
